Function.RegisterNamespace("Test.System.Script.Attributes");

[Fixture]
Test.System.Script.Attributes.Attribute=function(){
    [Fixture]
    function Attribute(){
        [Fact]
        function SetsNameIfPassed(){
            var expected="expected";
            
            var actual=new System.Script.Attributes.Attribute(expected).Name;
            
            Assert.Equal(expected,actual);
        }

        [Fact]
        function SetsNameToEmptyStringIfNotPassed(){
            var expected='';
            
            var actual=new System.Script.Attributes.Attribute().Name;
            
            Assert.Equal(expected,actual);
        }

        [Fact]
        function SetsTargetIfPassed(){
            var expected="expected";
            
            var actual=new System.Script.Attributes.Attribute(null,expected).Target;
            
            Assert.Equal(expected,actual);
        }

        [Fact]
        function SetsTargetToNullIfNotCalledByDecoratedFunction(){
            var actual=new System.Script.Attributes.Attribute();

            Assert.Null(actual.Target);
        }

        [Fact]
        function SetsTargetToCallingDecoratedFunction(){
            var expected=new System.Script.Attributes.DecoratedFunction(function(){},'expected',[System.Script.Attributes.Attribute]);

            var target=expected.GetDecoration().GetAttributes()[0];
            var actual=target.Target;
            
            Assert.Equal(expected,actual);
        }
    }
    
    [Fixture]
    function BeforeInvoke(){
        [Fact]
        function ImplementsBeforeInvoke(){
            var actual=Record.Exception(function(){
                new System.Script.Attributes.Attribute().BeforeInvoke();
            });
            
            Assert.Null(actual);
        }
    }

    [Fixture]
    function AfterInvoke(){
        [Fact]
        function ImplementsAfterInvoke(){
            var actual=Record.Exception(function(){
                new System.Script.Attributes.Attribute().AfterInvoke();
            });
            
            Assert.Null(actual);
        }
    }
}
